#include"process.h"
#include<string.h>
#include<unistd.h>

//void ForTest()
//{
  //printf("hh\n");

  //printf("hh\n");
  //printf("hh\n");
  //printf("hh\n");
  //printf("hh\n");
  //printf("hh\n");
//}

#define Length 101
#define Style '#'
const char *label = "|/-\\";
//void ProcBar()
//{
//    char bar[Length];
//    memset(bar,'\0',sizeof(bar));
//    int len=strlen(label);
//    int cnt = 0;
//    while(cnt<=100)
//    {
//      printf("[%-100s][%3d%%][%c]\r",bar,cnt,label[cnt%len]);
//      fflush(stdout);
//      bar[cnt++]=Style;
//      usleep(20000);
//    }
//    printf("\n");
//
//}

void ProcBar(double total,double current)
{
  char bar[Length];
  memset(bar,'\0',sizeof(bar));
  int len = strlen(label);
  int cnt = 0;
  double rate=(current*100)/total;
  int loop_count=(int)rate;
  while(cnt<=loop_count)
  {
    bar[cnt++]=Style;
  }
  printf("[%-100s][%.1lf%%][%c]\r",bar,rate,label[cnt%len]);
  fflush(stdout); 
}
